<!--
 * @Author: 高瑞寒 15932717091@163.com
 * @Date: 2022-01-15 20:01:02
 * @LastEditTime: 2022-03-15 16:55:59
 * @LastEditors: 高瑞寒 15932717091@163.com
 * @Description:
-->
<template>
  <el-config-provider  :locale="$store.getters.language === 'en' ? en : zhCn">
    <router-view />
  </el-config-provider>
</template>

<script setup>
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import en from 'element-plus/es/locale/lang/en'

import { generateNewStyle, writeNewStyle } from '@/utils/theme'
import { useStore } from 'vuex'
import { watchSwitchLang } from '@/utils/i18n'
const store = useStore()
generateNewStyle(store.getters.mainColor).then((newStyle) => {
  writeNewStyle(newStyle)
})

watchSwitchLang(() => {
  if (store.getters.token) {
    store.dispatch('user/getUserInfo')
  }
})
</script>

<style></style>
